﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public enum SCTType { HEALING, DAMAGE }
public class sctManager : MonoBehaviour
{
    private static sctManager instance;
    public static sctManager MyInstance
    {
        get
        {
            if (instance == null)
            {
                instance = FindObjectOfType<sctManager>();
            }
            return instance;
        }
    }
    [SerializeField]
    private GameObject prefabText;
    public void TextGen(string text,Vector2 pos, SCTType type, bool crit)
    {
        
        Text textSct= Instantiate(prefabText, transform).GetComponent<Text>();
        textSct.transform.position = pos;
        string operation=string.Empty;
        switch (type)
        {
            case SCTType.HEALING:
                operation += "+";
                textSct.color = new Color32(0, 255, 0, 255);
                break;
            case SCTType.DAMAGE:
                operation += "-";
                textSct.color = new Color32(255, 0, 0,255);
                break;
            default:
                break;
        }
        
        textSct.text = operation + text;
        if (crit)
        {
            textSct.GetComponent<Animator>().SetBool("crit", crit);
        }
    }
}
